package com.bgds.sys.module.controller;


import com.bgds.sys.common.pagevo.Result;
import com.bgds.sys.common.utils.ResultUtil;
import com.bgds.sys.module.entity.DeviceStaticAttr;
import com.bgds.sys.module.entity.dto.DeviceDto;
import com.bgds.sys.module.service.IDeviceService;
import com.bgds.sys.module.service.IDeviceStaticAttrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  设备前端控制器
 * </p>
 *
 * @author lj
 * @since 2020-01-07
 */
@RestController
@RequestMapping("/device")
@Api(tags = "设备接口")
public class DeviceController {

    @Autowired
    private IDeviceService iDeviceService;
    @Autowired
    private IDeviceStaticAttrService iDeviceStaticAttrService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "获取设备",notes = "获取设备",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "permId", dataType = "Long", value = "菜单ID")
    })
    public Result<List<DeviceDto>> list(Long permId){
        List<DeviceDto> deviceGroups=iDeviceService.listByParam(permId);
        return new ResultUtil<List<DeviceDto>>().setData(deviceGroups);
    }

    @RequestMapping(value = "/deviceStaticAttrs", method = RequestMethod.GET)
    @ApiOperation(value = "获取设备静态属性",notes = "获取设备静态属性",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", dataType = "String", required = true, value = "设备编号")
    })
    public Result<List<DeviceStaticAttr>> getStaticAttr(String deviceCode){
        List<DeviceStaticAttr> deviceStaticAttrs=iDeviceStaticAttrService.getStaticAttByDeviceCode(deviceCode);
        return new ResultUtil<List<DeviceStaticAttr>>().setData(deviceStaticAttrs);
    }


}

